<template>
  <div class="error-page">
    <div class="error-content">
      <!-- 左侧图形 -->
      <div
        class="error-illustration"
        v-motion
        :initial="{ opacity: 0, x: -50 }"
        :enter="{ opacity: 1, x: 0, transition: { delay: 200 } }"
      >
        <div class="error-code">404</div>
      </div>

      <!-- 右侧内容 -->
      <div
        class="error-info"
        v-motion
        :initial="{ opacity: 0, x: 50 }"
        :enter="{ opacity: 1, x: 0, transition: { delay: 400 } }"
      >
        <h1>页面不见了</h1>
        <p>抱歉，您访问的页面可能已经被删除或移动到其他位置</p>
        <div class="error-actions">
          <button class="btn-back" @click="goBack">
            <PhCaretLeft :size="17" color="#0d0d0d" weight="light" />
            <span>返回上页</span>
          </button>
          <button class="btn-home" @click="goHome">
            <PhHouse :size="17" color="#FAFAFA" weight="light" />
            <span>回到首页</span>
          </button>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router';
import { PhArrowFatLeft, PhArrowLeft, PhCaretLeft, PhHouse } from '@phosphor-icons/vue';

const router = useRouter();

const goBack = () => {
  router.back();
};
const goHome = () => {
  router.push('/');
};
</script>

<style lang="less" scoped>
.error-page {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f6f8ff 0%, #ffffff 100%);
  overflow: hidden;

  .error-content {
    display: flex;
    gap: 60px;
    align-items: center;
    max-width: 800px;
    padding: 60px;
    background: #ffffff;
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.05);
  }

  .error-illustration {
    position: relative;

    .error-code {
      font-size: 120px;
      font-weight: 700;
      background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      text-shadow: 0 2px 10px rgba(96, 165, 250, 0.2);
    }

    &::after {
      content: '';
      position: absolute;
      bottom: -10px;
      left: 50%;
      transform: translateX(-50%);
      width: 60%;
      height: 4px;
      background: linear-gradient(90deg, transparent, #60a5fa, transparent);
      border-radius: 2px;
      opacity: 0.3;
    }
  }

  .error-info {
    h1 {
      font-size: 32px;
      color: #60a5fa;
      margin-bottom: 16px;
      font-weight: 600;
    }

    p {
      font-size: 16px;
      color: #6b7280;
      margin-bottom: 32px;
      line-height: 1.6;
    }

    .error-actions {
      display: flex;
      gap: 16px;

      button {
        padding: 12px 24px;
        border-radius: 12px;
        font-size: 16px;
        display: flex;
        align-items: center;
        gap: 8px;
        cursor: pointer;
        transition: all 0.3s ease;
        border: none;

        &.btn-back {
          background: #f1f5f9;
          color: #475569;

          &:hover {
            background: #e2e8f0;
            transform: translateY(-2px);
          }
        }

        &.btn-home {
          // 修改后
          background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
          color: #ffffff;

          &:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
            opacity: 0.9;
          }
        }

        .icon {
          font-size: 18px;
          line-height: 1;
        }
      }
    }
  }
}

// 响应式设计
@media (max-width: 768px) {
  .error-page {
    .error-content {
      flex-direction: column;
      text-align: center;
      padding: 40px 24px;
      gap: 40px;
      margin: 20px;
    }

    .error-illustration {
      .error-code {
        font-size: 80px;
      }
    }

    .error-info {
      .error-actions {
        flex-direction: column;

        button {
          width: 100%;
          justify-content: center;
        }
      }
    }
  }
}

// 暗色模式支持
@media (prefers-color-scheme: dark) {
  .error-page {
    background: linear-gradient(135deg, #1a1a2e 0%, #1e1e24 100%);

    .error-content {
      background: rgba(255, 255, 255, 0.05);
      backdrop-filter: blur(10px);
    }

    .error-info {
      h1 {
        color: #60a5fa;
      }

      p {
        color: rgba(255, 255, 255, 0.7);
      }

      .error-actions {
        .btn-back {
          background: rgba(255, 255, 255, 0.1);
          color: rgba(255, 255, 255, 0.8);

          &:hover {
            background: rgba(255, 255, 255, 0.15);
          }
        }
      }
    }
  }
}
</style>
